#include<iostream>
#include<vector>
using namespace std;

struct ListNode
{
    int val;
    ListNode* next;
    ListNode() : val(0), next(NULL) {}
    ListNode(int x) : val(x), next(NULL) {}
    ListNode(int x, ListNode* next) : val(x), next(next) {}
};
class Solution {
public:
    ListNode* oddEvenList(ListNode* head) {
        ListNode h1, h2;
        ListNode *c1 = &h1, *c2 = &h2;
        int jug = 1;
        while (head)
        {
            if (jug)
            {
                c1->next = head;
                c1 = c1->next;
                jug = 0;
            }
            else
            {
                c2->next = head;
                c2 = c2->next;
                jug = 1;
            }
            head = head->next;
        }
        c1->next = h2.next;
        c2->next = nullptr;
        return h1.next;
    }
};
ListNode* createByTail()
{
    ListNode* head;
    ListNode* p1, * p2{};
    int n = 0, num;
    int len;
    cin >> len;
    head = NULL;
    while (n<len && cin >> num)
    {
        p1 = new ListNode(num);
        n = n + 1;
        if (n == 1)
            head = p1;
        else
            p2->next = p1;
        p2 = p1;
    }
    return head;
}
void  displayLink(ListNode* head)
{
    ListNode* p;
    p = head;
    cout << "head-->";
    while (p != NULL)
    {
        cout << p->val << "-->";
        p = p->next;
    }
    cout << "tail\n";
}
int main()
{
    ListNode* head = createByTail();
    head = Solution().oddEvenList(head);
    displayLink(head);
    return 0;
}